package com.rjgc.title.controller.apply;


import com.rjgc.title.common.result.Result;
import com.rjgc.title.model.entity.apply.Declare;
import com.rjgc.title.model.entity.user.CurrentTitle;
import com.rjgc.title.service.DeclareService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 申报表 前端控制器
 * </p>
 *
 * @author 卓抱抱
 * @since 2022-04-26
 */
@Api(tags = "申报表")
@RestController
@RequestMapping("/api/declarec")
public class DeclareController {

    @Autowired
    private DeclareService declareService;

    /**
     * 保存，更新
     *
     * @param declare
     * @return
     */
    @PostMapping("inner/save")
    public Result saveOrUpdate(@RequestBody Declare declare) {
        declareService.saveOrUpdate(declare);

        return Result.ok();
    }

    /**
     * 根据id查询
     *
     * @param
     * @return
     */
    @GetMapping("inner/getByUserId")
    public Result getById(HttpServletRequest request) {
        String userId = (String) request.getSession().getAttribute("userId");
        // 调用service方法进行查询
        Declare declare = declareService.getByUserId(userId);

        // 返回数据
        return Result.ok(declare);
    }

}

